class TagsReq {

  GetPostsByTag _getPostsByTagWindow;  
  String _url;
    
  TagsReq(GetPostsByTag getPostsByTagWindow, String url){
    _getPostsByTagWindow = getPostsByTagWindow;
    _url = url;
  }
    
    
    XMLHttpRequest getTagsFromServer() {
      XMLHttpRequest request = new XMLHttpRequest();
      request.on.readyStateChange.add((Event event) {
        if (request.readyState != 4) return;
          if (request.status == 200) {
            
            String json = JSON.parse(request.responseText);
            
           
            
            List tags = json.split(" ");
            _getPostsByTagWindow.addTags(tags);
            
          } else {  //on error
            document.query('#posts').innerHTML = 'error )-: while receiving tags';
          }
      });
      
      request.open("GET", _url, true);
      request.send();
      
      return request;
    }

}
